package com.sun.controller;

import com.sun.model.Dept;
import com.sun.service.DeptClientServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class DeptConsumerController {

    //那么此时该怎么调用service的功能呢？不在一起，服务部署在服务器上
    // (url,实体：map,ReturnClass<T>)

    @Autowired
    private DeptClientServer deptClientServer;

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/consumer/{id}")
    public Dept getDeptById(@PathVariable("id") Integer id) {
       return deptClientServer.queryDeptById(id);
    }

    @RequestMapping("/consumer/add")
    public boolean getDeptById(Dept dept) {
        return deptClientServer.addDept(dept);
    }

    @RequestMapping("/consumer/list")
    public List<Dept> getDeptList() {
        return deptClientServer.queryAll();
    }


}
